﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Data.Common;
using System.Data;

namespace ConnectToDatabase
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString;
            SqlConnection sqlConnection;
            SqlTransaction sqlTransaction;

            sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();

            sqlTransaction = sqlConnection.BeginTransaction();

            SqlCommand cmd = new SqlCommand("select * from Area", sqlConnection, sqlTransaction);
            // Create the DbDataAdapter.
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            // Fill the DataTable.
            DataTable table = new DataTable();
            da.Fill(table);

            Console.WriteLine(table.Rows.Count);
        }
    }
}
